package com.bjpowernode.boss.util;

import jakarta.annotation.Resource;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.concurrent.TimeUnit;

@Component
public class RedisClient {
    @Resource
    private StringRedisTemplate template;

    //    用hash类型存储jwt，loginid和登陆时间
    public Boolean addAllHash(String key, Map<String, String> data, int timeout, TimeUnit TimeUtil) {
        Boolean flag = true;
        template.opsForHash().putAll(key, data);
        if (timeout > 0) {

            flag = template.expire(key, timeout, TimeUtil);
        }
        return flag;
    }
}
